<template>
	<view>
		<view class="margin bg">
			
		</view>
		<view class="bg-white">
			<view class="text-center " @click="handleLogin">
				<view class="" style="">
					<!-- <image class="image" :src='src==null?"../../static/logo.png":src'  @click.stop="handlechoose"></image> -->
					<image class="image" :src='$store.state.user.img'  @click.stop="handlechoose"></image>
				</view>
				<text>{{userinfo.username?userinfo.username:'未登录'}}</text>
			</view>
			
			<view class="flex justify-around margin">
				<view v-for="(item,index) in arr" :key="index" class="flex flex-direction align-center ">
					<text :class="['iconfont margin-bottom-xs',item.icon]"></text>
					<view class>
						我的订单
					</view>
				</view>
			</view>
			<view class="flex justify-around margin">
				<view v-for="(item,index) in arr" :key="index" class="flex flex-direction align-center ">
					<text :class="['iconfont margin-bottom-xs',item.icon]"></text>
					<view class>
						我的订单
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				arr:[	
					{
						icon:"icon-danju",
						name:"我的订单"
					},{
						icon:"icon-jifen",
						name:"待收货"
					},
					{
						icon:"icon-ziliaoshouce",
						name:"待付款"
					},
					{
						icon:"icon-vip-fill",
						name:"会员等级"
					}
				],
				src:null
			}
		},
		methods: {
			handleLogin(){
				uni.navigateTo({
					url:'../login/login'
				})
			},
			handlechoose(){
				let that = this
				uni.chooseImage({
					count: 6, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function (res) {
						console.log(res.tempFilePaths);
						that.src = res.tempFilePaths[0]
						uni.setStorage({
							key:'img',	
							data:that.src
						})
						that.$store.commit('user/initimg',that.src)
						console.log(that.src)
					}
				});
			}
		},
		computed:{
			userinfo(){
				var username
				uni.getStorage({
					key:"username",
					success: (res) => {
						 console.log(res.data);
						 username = res.data
					}
				})
				return username?username:'未登录'
			}
		}
	}
</script>

<style lang="scss">
page{
	background-color: #F6f6f6;
}
.flex .iconfont{
	font-size: 60upx;
	color: #888;
}
.image{
	width: 150upx;
	height: 150upx;
	border-radius:50% ;
	margin-top: -75upx;
}
.bg{
	height: 200upx;
}
</style>
